﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using NUnit.Framework;
using TeamsPortal.Web.Extensions;

namespace TeamsPortal.Tests
{
    [TestFixture]
    public class StringExtensionsTests
    {
        [Test]
        public void ToUrlSegment_ReplacePathInvalidCharacters()
        {
            //char[] invalidChars = new char[] {'<', '>', '*', '%', '&', ':', '\\'};
            char[] invalidChars = new char[] { '?', ':' };
            var urlBuilder = new StringBuilder();
            foreach (var c in invalidChars)
            {
                urlBuilder.AppendFormat("url{0}", c);
            }

            string result = urlBuilder.ToString().ToUrlSegment(100);
            Assert.IsNotNullOrEmpty(result);
            Assert.AreEqual(-1, result.IndexOfAny(invalidChars));
        }
    }
}
